<!DOCTYPE html>
<html><head>
    <meta charset="utf-8">
    <title>童老师ThinkPHP交流群：484519446</title>

    <meta name="description" content="Dashboard">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!--Basic Styles-->
    <link href="__PUBLIC__/style/bootstrap.css" rel="stylesheet">
    <link href="__PUBLIC__/style/font-awesome.css" rel="stylesheet">
    <link href="__PUBLIC__/style/weather-icons.css" rel="stylesheet">

    <!--Beyond styles-->
    <link id="beyond-link" href="__PUBLIC__/style/beyond.css" rel="stylesheet" type="text/css">
    <link href="__PUBLIC__/style/demo.css" rel="stylesheet">
    <link href="__PUBLIC__/style/typicons.css" rel="stylesheet">
    <link href="__PUBLIC__/style/animate.css" rel="stylesheet">

</head>
<body>
<!-- 头部 -->
{include file="common/top"/}
<!-- /头部 -->

<div class="main-container container-fluid">
    <div class="page-container">
        <!-- Page Sidebar -->
        {include file="common/left"/}
        <!-- /Page Sidebar -->
        <!-- Page Content -->
        <div class="page-content">
            <!-- Page Breadcrumb -->
            <div class="page-breadcrumbs">
                <ul class="breadcrumb">
                    <li>
                        <a href="#">系统</a>
                    </li>
                    <li>
                        <a href={:url("authGroup/lst")}>用户组管理</a>
                    </li>
                    <li class="active">修改用户组</li>
                </ul>
            </div>
            <!-- /Page Breadcrumb -->

            <!-- Page Body -->
            <div class="page-body">

                <div class="row">
                    <div class="col-lg-12 col-sm-12 col-xs-12">
                        <div class="widget">
                            <div class="widget-header bordered-bottom bordered-blue">
                                <span class="widget-caption">修改用户组</span>
                            </div>
                            <div class="widget-body">
                                <div id="horizontal-form">
                                    <form class="form-horizontal" role="form" action="" method="post">
                                        <input type="hidden" name="id" value="{$authGroups.id}">
                                        <div class="form-group">
                                            <label  class="col-sm-2 control-label no-padding-right">用户组标题</label>
                                            <div class="col-sm-6">
                                                <input class="form-control" id="title" placeholder="" name="title" value="{$authGroups.title}"  type="text">
                                            </div>
                                            <p class="help-block col-sm-4 red">* 必填</p>
                                        </div>

                                        <div class="form-group">
                                            <label  class="col-sm-2 control-label no-padding-right">启用状态</label>
                                            <div class="col-sm-6">
                                                <label>
                                                    <input class="checkbox-slider colored-darkorange" type="checkbox" {if condition="$authGroups['status'] eq 1"}checked="checked"{/if} id="status" name="status" >
                                                    <span class="text"></span>
                                                </label>
                                            </div>
                                            <p class="help-block col-sm-4 red">* 必填</p>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-2 control-label no-padding-right"></label>
                                            <div class="col-sm-6">
                                                <table class="table table-hover">
                                                    <thead class="bordered-darkorange">
                                                    <tr>
                                                        <th>
                                                            配置权限
                                                        </th>
                                                    </tr>
                                                    </thead>
                                                    <tbody>
                                                    {volist name="authrules" id="vo"}
                                                    <tr>
                                                        <th>
                                                            <label>
                                                                <?php echo str_repeat("&nbsp;",$vo['level']*4);?>
                                                                <input name="rules[]" value="{$vo.id}" dataid="id-{$vo.dataid}"  class="inverted checkbox-parent
                                                                {if condition="$vo['level'] neq 0"} checkbox-child {/if}"
                                                                <?php
                                                                $arr = explode(',',$authGroups['rules']);
                                                                if(in_array($vo['id'],$arr)){
                                                                    echo "checked='checked'";
                                                                }
                                                                ?>
                                                                type="checkbox">
                                                                <span class="text">{$vo.title}</span>
                                                            </label>
                                                        </th>
                                                    </tr>
                                                    {/volist}
                                                    </tbody>
                                                </table>
                                            </div>

                                        </div>
                                        <div class="form-group">
                                            <div class="col-sm-offset-2 col-sm-10">
                                                <button type="submit" class="btn btn-default">保存信息</button>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
            <!-- /Page Body -->
        </div>
        <!-- /Page Content -->
    </div>
</div>

<!--Basic Scripts-->
<script src="__PUBLIC__/style/jquery_002.js"></script>
<script src="__PUBLIC__/style/bootstrap.js"></script>
<script src="__PUBLIC__/style/jquery.js"></script>
<!--Beyond Scripts-->
<script src="__PUBLIC__/style/beyond.js"></script>
<script type="text/javascript">
    /* 权限配置 */
    $(function () {
        //动态选择框，上下级选中状态变化
        $('input.checkbox-parent').on('change', function () {
            var dataid = $(this).attr("dataid");
            $('input[dataid^=' + dataid + ']').prop('checked', $(this).is(':checked'));
        });
        $('input.checkbox-child').on('change', function () {
            var dataid = $(this).attr("dataid");
            dataid = dataid.substring(0, dataid.lastIndexOf("-"));
            var parent = $('input[dataid=' + dataid + ']');
            if ($(this).is(':checked')) {
                parent.prop('checked', true);
                //循环到顶级
                while (dataid.lastIndexOf("-") != 2) {
                    dataid = dataid.substring(0, dataid.lastIndexOf("-"));
                    parent = $('input[dataid=' + dataid + ']');
                    parent.prop('checked', true);
                }
            } else {
                //父级
                if ($('input[dataid^=' + dataid + '-]:checked').length == 0) {
                    parent.prop('checked', false);
                    //循环到顶级
                    while (dataid.lastIndexOf("-") != 2) {
                        dataid = dataid.substring(0, dataid.lastIndexOf("-"));
                        parent = $('input[dataid=' + dataid + ']');
                        if ($('input[dataid^=' + dataid + '-]:checked').length == 0) {
                            parent.prop('checked', false);
                        }
                    }
                }
            }
        });
    });
</script>



</body></html>